package com.cms.bs.app.model;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by jiang on 2016-10-27.
 */
@Entity
@Table(name = "s_role")
public class Role {
    @Id
    private long id;
    private String name;
    private String description;

//    @ManyToMany(mappedBy = "roles")
//    private List<User> users = new ArrayList<User>();

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "s_role_resource", joinColumns = {@JoinColumn(name = "roleId", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "resourceId", referencedColumnName = "id")})
    private List<Resource> resources = new ArrayList<Resource>();

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Resource> getResources() {
        return resources;
    }

    public void setResources(List<Resource> resources) {
        this.resources = resources;
    }
}
